//
//  MJ_UserLoginUserLoginDetail.m
//
//  Created by   on 2017/12/27
//  Copyright (c) 2017 __MyCompanyName__. All rights reserved.
//

#import "MJ_UserLoginUserLoginDetail.h"


NSString *const kMJ_UserLoginUserLoginDetailPhone = @"phone";
NSString *const kMJ_UserLoginUserLoginDetailTaskType = @"taskType";
NSString *const kMJ_UserLoginUserLoginDetailIsValidity = @"isValidity";
NSString *const kMJ_UserLoginUserLoginDetailUserId = @"userId";
NSString *const kMJ_UserLoginUserLoginDetailIsExaminate = @"isExaminate";
NSString *const kMJ_UserLoginUserLoginDetailDomainName = @"domainName";
NSString *const kMJ_UserLoginUserLoginDetailTeamId = @"teamId";
NSString *const kMJ_UserLoginUserLoginDetailToken = @"token";
NSString *const kMJ_UserLoginUserLoginDetailUserType = @"userType";
NSString *const kMJ_UserLoginUserLoginDetailUrl = @"url";


@interface MJ_UserLoginUserLoginDetail ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation MJ_UserLoginUserLoginDetail

@synthesize phone = _phone;
@synthesize taskType = _taskType;
@synthesize isValidity = _isValidity;
@synthesize userId = _userId;
@synthesize isExaminate = _isExaminate;
@synthesize domainName = _domainName;
@synthesize teamId = _teamId;
@synthesize token = _token;
@synthesize userType = _userType;
@synthesize url = _url;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict {
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict {
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if (self && [dict isKindOfClass:[NSDictionary class]]) {
            self.phone = [self objectOrNilForKey:kMJ_UserLoginUserLoginDetailPhone fromDictionary:dict];
            self.taskType = [[self objectOrNilForKey:kMJ_UserLoginUserLoginDetailTaskType fromDictionary:dict] doubleValue];
            self.isValidity = [[self objectOrNilForKey:kMJ_UserLoginUserLoginDetailIsValidity fromDictionary:dict] doubleValue];
            self.userId = [[self objectOrNilForKey:kMJ_UserLoginUserLoginDetailUserId fromDictionary:dict] doubleValue];
            self.isExaminate = [self objectOrNilForKey:kMJ_UserLoginUserLoginDetailIsExaminate fromDictionary:dict];
            self.domainName = [self objectOrNilForKey:kMJ_UserLoginUserLoginDetailDomainName fromDictionary:dict];
            self.teamId = [[self objectOrNilForKey:kMJ_UserLoginUserLoginDetailTeamId fromDictionary:dict] doubleValue];
            self.token = [self objectOrNilForKey:kMJ_UserLoginUserLoginDetailToken fromDictionary:dict];
            self.userType = [[self objectOrNilForKey:kMJ_UserLoginUserLoginDetailUserType fromDictionary:dict] doubleValue];
            self.url = [self objectOrNilForKey:kMJ_UserLoginUserLoginDetailUrl fromDictionary:dict];

    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation {
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.phone forKey:kMJ_UserLoginUserLoginDetailPhone];
    [mutableDict setValue:[NSNumber numberWithDouble:self.taskType] forKey:kMJ_UserLoginUserLoginDetailTaskType];
    [mutableDict setValue:[NSNumber numberWithDouble:self.isValidity] forKey:kMJ_UserLoginUserLoginDetailIsValidity];
    [mutableDict setValue:[NSNumber numberWithDouble:self.userId] forKey:kMJ_UserLoginUserLoginDetailUserId];
    [mutableDict setValue:self.isExaminate forKey:kMJ_UserLoginUserLoginDetailIsExaminate];
    [mutableDict setValue:self.domainName forKey:kMJ_UserLoginUserLoginDetailDomainName];
    [mutableDict setValue:[NSNumber numberWithDouble:self.teamId] forKey:kMJ_UserLoginUserLoginDetailTeamId];
    [mutableDict setValue:self.token forKey:kMJ_UserLoginUserLoginDetailToken];
    [mutableDict setValue:[NSNumber numberWithDouble:self.userType] forKey:kMJ_UserLoginUserLoginDetailUserType];
    [mutableDict setValue:self.url forKey:kMJ_UserLoginUserLoginDetailUrl];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description  {
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict {
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super init];

    self.phone = [aDecoder decodeObjectForKey:kMJ_UserLoginUserLoginDetailPhone];
    self.taskType = [aDecoder decodeDoubleForKey:kMJ_UserLoginUserLoginDetailTaskType];
    self.isValidity = [aDecoder decodeDoubleForKey:kMJ_UserLoginUserLoginDetailIsValidity];
    self.userId = [aDecoder decodeDoubleForKey:kMJ_UserLoginUserLoginDetailUserId];
    self.isExaminate = [aDecoder decodeObjectForKey:kMJ_UserLoginUserLoginDetailIsExaminate];
    self.domainName = [aDecoder decodeObjectForKey:kMJ_UserLoginUserLoginDetailDomainName];
    self.teamId = [aDecoder decodeDoubleForKey:kMJ_UserLoginUserLoginDetailTeamId];
    self.token = [aDecoder decodeObjectForKey:kMJ_UserLoginUserLoginDetailToken];
    self.userType = [aDecoder decodeDoubleForKey:kMJ_UserLoginUserLoginDetailUserType];
    self.url = [aDecoder decodeObjectForKey:kMJ_UserLoginUserLoginDetailUrl];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_phone forKey:kMJ_UserLoginUserLoginDetailPhone];
    [aCoder encodeDouble:_taskType forKey:kMJ_UserLoginUserLoginDetailTaskType];
    [aCoder encodeDouble:_isValidity forKey:kMJ_UserLoginUserLoginDetailIsValidity];
    [aCoder encodeDouble:_userId forKey:kMJ_UserLoginUserLoginDetailUserId];
    [aCoder encodeObject:_isExaminate forKey:kMJ_UserLoginUserLoginDetailIsExaminate];
    [aCoder encodeObject:_domainName forKey:kMJ_UserLoginUserLoginDetailDomainName];
    [aCoder encodeDouble:_teamId forKey:kMJ_UserLoginUserLoginDetailTeamId];
    [aCoder encodeObject:_token forKey:kMJ_UserLoginUserLoginDetailToken];
    [aCoder encodeDouble:_userType forKey:kMJ_UserLoginUserLoginDetailUserType];
    [aCoder encodeObject:_url forKey:kMJ_UserLoginUserLoginDetailUrl];
}

- (id)copyWithZone:(NSZone *)zone {
    MJ_UserLoginUserLoginDetail *copy = [[MJ_UserLoginUserLoginDetail alloc] init];
    
    
    
    if (copy) {

        copy.phone = [self.phone copyWithZone:zone];
        copy.taskType = self.taskType;
        copy.isValidity = self.isValidity;
        copy.userId = self.userId;
        copy.isExaminate = [self.isExaminate copyWithZone:zone];
        copy.domainName = [self.domainName copyWithZone:zone];
        copy.teamId = self.teamId;
        copy.token = [self.token copyWithZone:zone];
        copy.userType = self.userType;
        copy.url = [self.url copyWithZone:zone];
    }
    
    return copy;
}


@end
